package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/customer")
public class CustomerController {

    @Autowired
    CustomerService customerService;

    @RequestMapping("/list")
    @RequiresPermissions(value = "客户管理")// 有客户管理菜单权限的才给予调用
    public Map<String,Object> list (Integer page,Integer rows, String customerName){
        return customerService.list(page,rows,customerName);
    }


    @RequestMapping("/save")
    @RequiresPermissions(value = "客户管理")
    public ServiceVO save (Customer customer){
        return customerService.save(customer);
    }

    @RequestMapping("/delete")
    @RequiresPermissions(value = "客户管理")
    public ServiceVO delete(String ids){
        return customerService.delete(ids);
    }

    @RequestMapping("/getComboboxList")
    @RequiresPermissions(value={"销售出库","客户退货","销售单据查询","客户退货查询","客户统计"},logical= Logical.OR)

    public List<Customer> getComboboxList(String q){

        return customerService.getComboboxList(q);

    }



}
